SkillSpellLightning = class("SkillSpellLightning")

function SkillSpellLightning:ctor( ... )
	local arg = {...}
	if(#arg ~= 4) then
		GameLog.Error("SkillSpellLightning ctor param number is not 4.")
		return
	end

	self.id = arg[1]
	self.spellData = arg[2]
	self.role = arg[3]
	self.target = arg[4]
end

function SkillSpellLightning:play()
	self.updateTime = 0

	self.res = ObjectPoolManager:GetObjectForce(self.spellData.res_name)
	self.transform = self.res:animationController(typeof(UnityEngine.Transform))
	self.transform.position = self.target.transform
	--self.animationController = self.res:animationController(typeof(SpineAnimationController))
	--self.animationController.PlayAnimation(self.spellData.animName)
	self.isPlaying = true
	
	UpdateBeat:Add(self.update, self)
end

function SkillSpellLightning:update()
	self.updateTime = self.updateTime + Time.deltaTime
	if(self.isPlaying and self.updateTime >= self.spellData.duration) then
		self.isPlaying = false
		--self.animationController.StopAnimation()
		ActionPlayer.removeSpellLightning(self.id)
	end
end

function SkillSpellLightning:destroy()
	self.spellData = nil
	self.role = nil
	self.target = nil

	self.res = nil
	self.transform = nil

	UpdateBeat:Remove(self.update, self)
end